package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.douluodalu.DouLuoDaLuModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_DOU_LUO_DA_LU_BAO_KU_SYNC_RECORD, desc = "同步试炼宝库日志（跑马灯）")
public class DouLuoDaLuBroadcastBaoKuDrawRecordCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        DouLuoDaLuProto.SyncDouLuoDaLuTryTrainRecordRespMsg reqMsg = DouLuoDaLuProto.SyncDouLuoDaLuTryTrainRecordRespMsg.parseFrom(packet.getBytes());
        for (GamePlayer gamePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
//            if(gamePlayer.getUserId() == reqMsg.getRecord().getUserId()){
//                continue;
//            }
            if(gamePlayer.getModule(DouLuoDaLuModule.class).getUserData() == null){
                continue;
            }
            gamePlayer.sendPacket(Protocol.U_DOU_LUO_DA_LU_BAO_KU_SYNC_RECORD, reqMsg.toBuilder());
        }
    }
}
